package pri.black.garden.domain.vo;

import lombok.Data;
import pri.black.garden.domain.Plan;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.LinkedList;
import java.util.List;

@Data
public class WeekPlanVO {
    private String weekDayName;
    private Integer weekDayValue;
    private Integer dayOfMonth;
    private Integer monthValue;
    private Integer yearValue;
    private Boolean today = false;
    private Boolean showAction = false;
    private String dateString;
    private Boolean holiday = false;

    private List<Plan> plans = new LinkedList<>();

    private String dayName(Integer dayOfWeek) {
        String[] sources = {"一","二","三","四","五","六","日"};
        return sources[dayOfWeek - 1];
    }

    public WeekPlanVO(LocalDate day){
        this.dayOfMonth = day.getDayOfMonth();
        this.monthValue = day.getMonthValue();
        this.yearValue = day.getYear();
        this.weekDayValue = day.getDayOfWeek().getValue();
        this.weekDayName = dayName(this.weekDayValue);
        this.dateString = day.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    }

    public void addPlan(Plan plan) {
        this.plans.add(plan);
    }
}
